package com.hy.dao.impl;
/*
 * @ Date: 2024/5/14 22:32
 * @ Description: OutsotreOrdertableDaoImpl
 **/

import com.hy.bean.OutsotreOrdertable;
import com.hy.dao.OutsotreOrdertableDao;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.ScalarHandler;

import java.math.BigInteger;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

public class OutsotreOrdertableDaoImpl implements OutsotreOrdertableDao {
    private QueryRunner queryRunner = new QueryRunner();
    @Override
    public OutsotreOrdertable queryById(Integer id) {
        return null;
    }

    @Override
    public List<OutsotreOrdertable> queryAllByLimit() {
        return null;
    }

    @Override
    public long count(OutsotreOrdertable outsotreOrdertable) {
        return 0;
    }

    /***
     * 添加出库中间表
     * @param connection
     * @param outsotreOrdertable 实例对象
     * @return
     */
    @Override
    public int insert(Connection connection,OutsotreOrdertable outsotreOrdertable) {
        String sql = "INSERT INTO outsotre_ordertable (`id`, `outStoreTable_id`, `partTable_id`, `outStoreNumber`) VALUES (null, ?, ?, ?)";
        try {
            BigInteger integer = queryRunner.insert(connection,sql,new ScalarHandler<>(),outsotreOrdertable.getOutstoretableId(),outsotreOrdertable.getParttableId(),outsotreOrdertable.getOutstorenumber());
            return integer.intValue();
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public int update(OutsotreOrdertable outsotreOrdertable) {
        return 0;
    }

    @Override
    public int deleteById(Integer id) {
        return 0;
    }
}
